extends Card
#枯荣转
@export var optional_sound: AudioStream


func get_default_tooltip() -> String:
	return tooltip_text


func get_updated_tooltip(_player_modifiers: ModifierHandler, _enemy_modifiers: ModifierHandler) -> String: # step 7.1
	return tooltip_text


func apply_effects(targets: Array[Node], _modifiers: ModifierHandler) -> void:
	print("枯荣转卡牌被使用！")
	
	var player = null
	
	# 通过targets参数获取场景树
	if targets.size() > 0:
		var tree = targets[0].get_tree()
		player = tree.get_first_node_in_group("player")
		
		if player and player.stats:
			# 记录旧的贷款值
			#var old_loan_mana = player.stats.old_loan_mana
			var new_loan_mana = player.stats.new_loan_mana
			
			#print("枯荣转效果触发前 - old_loan_mana: %d, new_loan_mana: %d" % [old_loan_mana, new_loan_mana])
			
			# 将两种贷款都归零
			#player.stats.old_loan_mana = 0
			player.stats.new_loan_mana = 0
			
			#print("枯荣转效果触发后 - old_loan_mana: %d → 0, new_loan_mana: %d → 0" % [old_loan_mana, new_loan_mana])
			print("角色回合内已恢复所有贷款！")
			
			# 播放音效
			if sound:
				SFXPlayer.play(sound)
			elif optional_sound:
				SFXPlayer.play(optional_sound)
		else:
			print("无法获取玩家或玩家状态")
	else:
		print("没有目标，无法执行效果")
